const express = require('express');
const router = express.Router();

router.get('/', (req, res) => { 
    const content = [];
    for(let i = 0; i < 30; i++)
        content.push({
            id: `2019${i}`,
            brandCode: `brandCode${i}`,
            code: `code${i}`,
            name: `name${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            country: '中国',
            marketDepartmentName: 'marketDepartmentName',
            totalInvestAmount: 213.21,
            totalSupportAmount: 3131.21,
            totalSupportRatio: 431.12,
            currency: 1,
            startDate: '2020-03-02T07:49:31.607Z',
            endDate: '2020-03-02T07:49:31.607Z',
            status: 1,
            createTime: '2020-03-02T07:49:31.607Z',
            lcStatus: 1,
            rowVersion: 'rowVersion',
            options: [
                'update',
                'abandon',
                'submit',
                'approve',
                'upload',
                'approveReport',
                'approveFee',
                'register',
                'exportExcel',
                'exportPdf'
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 30,
        }
    });
});
router.get('/forSaleConfirmation', (req, res) => {
    const content = [];
    for(let i = 0; i < 50; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            lcCode: `lcCode00${i}`,
            versionCode: `${i}`,
            issueCountry: '中国',
            issueBank: '中国银行',
            issuePrice: '550',
            issueDate: '2020-03-02T07:49:31.607Z',
            currency: 1,
            lcKind: 1,
            effectiveDate: '2020-03-02T07:49:31.607Z',
            expirationDate: '2020-03-02T07:49:31.607Z',
            creatorName: 'creatorName',
            createTime: '2020-03-02T07:49:31.607Z',
            lcStatus: 1,
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/:id', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            brandId: 'brandId001',
            brandCode: 'brandCode',
            brandName: 'brandName',
            dealerId: 'dealerId001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            code: 'code',
            name: 'name',
            country: '中国',
            marketDepartmentId: 'marketDepartmentId',
            marketDepartmentName: 'marketDepartmentName',
            totalInvestAmount: 1231.31,
            totalSupportAmount: 12.21,
            totalSupportRatio: 12312.21,
            currency: 1,
            startDate: '2020-03-02T08:40:53.602Z',
            endDate: '2020-03-02T08:40:53.602Z',
            status: 1,
            creatorName: 'creatorName',
            createTime: '2020-03-02T08:40:53.602Z',
            updatorName: 'updatorName',
            updateTime: '2020-03-02T08:40:53.602Z',
            submitterName: 'submitterName',
            submitTime: '2020-03-02T08:40:53.602Z',
            approverName: 'approverName',
            approveTime: '2020-03-02T08:40:53.602Z',
            abandonerName: 'abandonerName',
            abandonTime: '2020-03-02T08:40:53.602Z',
            remark: 'remark',
            rowVersion: 'string',
            options: [
                'update',
                'abandon',
                'submit',
                'approve',
                'upload',
                'approveReport',
                'approveFee',
                'register',
                'exportExcel',
                'exportPdf'
            ],
            attachments: [
                {
                    fileId: 'fileId001',
                    fileName: 'fileName001'
                }
            ],
            marketingActivityDetails: [
                {
                    id: '001',
                    order: '12',
                    item: 'item',
                    itemType: 1,
                    fundSource: 1,
                    investAmount: 2131.12,
                    supportAmount: 213.23,
                    supportRatio: 0.12,
                    detailRemark: 'detailRemark',
                }
            ],
            marketingActivityApprovalRecords: [
                {
                    id: '001',
                    approverCode: 'approverCode',
                    approverName: 'approverName',
                    approveResult: 1,
                    approveTime: '2020-03-03T09:30:33.129Z',
                    approveComment: 'approveComment',
                    nextOperation: 'nextOperation',
                }
            ]
        }
    });
});

router.post('/', async(req, res, next) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', async(req, res, next) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/receive', (req, res) => {
    res.json(
        {
            message: '到款登记成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json(
        {
            message: '作废成功'
        }
    );
});

router.put('/:id/exportExcel', (req, res) => {
    res.json(
        {
            message: '导出excel成功'
        }
    );
});

router.put('/:id/approvePass', (req, res) => {
    res.json(
        {
            message: '审核通过'
        }
    );
});

router.put('/:id/approveReject', (req, res) => {
    res.json(
        {
            message: '审核不通过'
        }
    );
});

router.put('/:id/upload', (req, res) => {
    res.json(
        {
            message: '上传报告和发票成功'
        }
    );
});

router.put('/:id/approveReport', (req, res) => {
    res.json(
        {
            message: '审核报告和发票通过'
        }
    );
});

router.put('/:id/approveReportReject', (req, res) => {
    res.json(
        {
            message: '审核报告和发票不通过'
        }
    );
});

router.put('/:id/approveFee', (req, res) => {
    res.json(
        {
            message: '审核发票和费用通过'
        }
    );
});

router.put('/:id/approveFeeReject', (req, res) => {
    res.json(
        {
            message: '审核发票和费用不通过'
        }
    );
});

router.put('/:id/register', (req, res) => {
    res.json(
        {
            message: '登记核销结果成功'
        }
    );
});

router.put('/:id/submit', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.get('/export', async(req, res, next) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});

router.post('/import', (req, res) => {
    res.json({
        message: 'success',
        payload: '导入成功'
    });
});

module.exports = router;
